home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 46
/
Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso
/
-in_the_mag-
/
reader_requests
/
scilab
/
man
/
man-part1
/
cat6
/
odedc.6
< prev
next >
Wrap
Text File
|
1999-09-16
|
3KB
|
133 lines
odedc(G) Scilab Function odedc(G)
NAME
odedc - discrete/continuous ode solver
CALLING SEQUENCE
yt=odedc(y0,nd,stdel,t0,t,f)
PARAMETERS
y0 : real column vector (initial conditions),y0=[y0c;y0d] where y0d
has nd components.
nd : integer, dimension of y0d
stdel : real vector with two entries, stdel=[step, delay]
t0 : real scalar (initial time).
t : real (row) vector, instants where yt is calculated
f : Scilab "external" i.e. function or character string or list
with calling sequence: yp=f(t,yc,yd,flag)
DESCRIPTION
y=odedc([y0c;y0d],nd,[h,delta],t0,t,f) computes the solution of:
dyc/dt=f(t,yc,yd,0) , yc(t0)=y0c,
such that at instants td=[delta, delta+h, delta+2*h,...] the discrete vari-
able yd is updated by:
yd(td+)=f(yc(t-),yd(t-1),1)
The calling parameters of f are fixed: xcd=f(t,xc,xd,flag); this function
must return the derivative of the vector xc if flag=0 and the update of xd
if flag=1.
t is a vector of instants where the solution y is computed.
y is the vector y=[y(t(1)),y(t(2)),...]. This function can be called with
the same optional parameters as the ode function (provided nd and stdel are
given in the calling sequence as second and third parameters). It particu-
lar integration flags, tolerances can be set. Optional parameters can be
set by the odeoptions function.
EXAMPLE
//Linear system with switching input
deff('xdu=f(t,x,u,flag)','if flag=0 then xdu=A*x+B*u; else xdu=1-u;end');
x0=[1;1];A=[-1,2;-2,-1];B=[1;2];u=0;nu=1;stdel=[1,0];u0=0;t=0:0.05:10;
xu=odedc([x0;u0],nu,stdel,0,t,f);x=xu(1:2,:);u=xu(3,:);
[xi,xa,npx]=graduate(min(t),1.1*max(t));
[yi,ya,npy]=graduate(1.1*min(min(x),min(u)),1.1*max(max(x),max(u)));
rect=[xi,yi,xa,ya];nx=2;//cont. componemts
plot2d1('onn',t',x',-[1:nx],'111',' ',rect,[4,npx,2,npy]);
plot2d2('onn',t',u',-[nx+1:nx+nu],'111',' ',rect,[4,npx,2,npy]);
//Sampled feedback
//
// | xcdot=fc(t,xc,u)
// (system) |
// | y=hc(t,xc)
//
//
// | xd+=fd(xd,y)
// (feedback) |
// | u=hd(t,xd)
//
deff('xcd=f(t,xc,xd,iflag)',...
xcd=fc(t,xc,e(t)-hd(t,xd));...
else xcd=fd(xd,hc(t,xc));end');
comp(f);
A=[-10,2,3;4,-10,6;7,8,-10];B=[1;1;1];C=[1,1,1];
Ad=[1/2,1;0,1/20];Bd=[1;1];Cd=[1,1];
deff('st=e(t)','st=sin(3*t)')
deff('xdot=fc(t,x,u)','xdot=A*x+B*u')
deff('y=hc(t,x)','y=C*x')
deff('xp=fd(x,y)','xp=Ad*x + Bd*y')
deff('u=hd(t,x)','u=Cd*x')
comp(e);comp(fc);comp(hc);comp(fd);comp(hd);
h=0.1;t0=0;t=0:0.1:2;
x0c=[0;0;0];x0d=[0;0];nd=2;
xcd=odedc([x0c;x0d],nd,h,t0,t,f);
plot2d([t',t',t'],xcd(1:3,:)');
xset("window",2);plot2d2("gnn",[t',t'],xcd(4:5,:)');
xset("window",0);
SEE ALSO
ode, odeoptions, csim, external, directory SCIDIR/default